<template>
	<view>
	<u-tag text="想要商品" type="primary" />
		<view v-for="(item,index) in detail" :key="index">
			<view class="content"  >
				<view class="title">
					{{item.title}}
				</view>
			</view>
			<view class="content">
				{{item.content}}
			</view>
			<view class="adress">
			<u-tag text="商品位置" type="primary" />
				<view class="adressname">
				{{item.adress}}
				</view>
			</view>
			<!-- 交易方式 -->
			<view class="way">
				<u-tag text="交易方式" type="primary" />
				<view class="waytext">
					<text>自行协商||自提||送货上门||约定交易地点||当面交易</text>
				</view>
			</view>
			<!-- 发布时间 -->
			<view class="time">
				<u-tag text="发布时间" type="primary" />
				<view class="timetext">
				<uni-dateformat  :date="item.last_modify_date" format="yyyy-MM-dd"
					:threshold="[60000, 2592000000]" />
				</view>
			</view>
			<view class="warning">
				<u-tag text="特别提醒" type="primary" />
				<view class="warning-text">
					<text>1.请坚决不要提前私下微信，支付宝等转账付款,付定金，会被拉黑财物两空.</text>
					<text>2.建议当面交易，一手交钱一手交货，更加安全.</text>
				</view>
			</view>
		</view>
		<u-tabbar v-model="current" :list="list" ></u-tabbar>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				// 当前显示 _id
				_id: "",
				title: 'title',
				detail:[],
				banner:[],
				// 数据表名
				// 查询字段，多个字段用 , 分割
				list: [{
										iconPath: "tags",
										selectedIconPath: "tags-fill",
										text: '分享',
										
										
										customIcon: false,
									},
									{
										iconPath: "star",
										selectedIconPath: "star-fill",
										text: '收藏',
										customIcon: false,
									},
									{
										iconPath: "info-circle",
										selectedIconPath: "info-circle-fill",
										text: '举报',
										midButton: true,
										customIcon: false,
									},
									{
										iconPath: "chat",
										selectedIconPath: "chat-fill",
										text: '先聊聊',
										customIcon: false,
									},
									{
										iconPath: "man-add",
										selectedIconPath: "man-add-fill",
										text: '加微信',
										isDot: false,
										customIcon: false,
									},
								],
								current:'0'
			}
		},
		onLoad(event){
			this._id=event.id
			this.getbuy()
		},
		onNavigationBarButtonTap(event) {
				if (event.type == 'share') {
					this.shareClick();
				}
			},
			
			methods: {
				
				
				
				setReadNewsLog(){
					let item = {
						"article_id":this.id,
						"last_time":Date.now()
					},
					readNewsLog = uni.getStorageSync('readNewsLog')||[],
					index = -1;
					readNewsLog.forEach(({article_id},i)=>{
						if(article_id == item.article_id){
							index = i
						}
					})
					if(index === -1){
						readNewsLog.push(item)
					}else{
						readNewsLog.splice(index,1,item)
					}
					uni.setStorageSync('readNewsLog',readNewsLog)
					console.log(readNewsLog);
				},
				getbuy(){
					const db=uniCloud.database()
					db.collection('buy1').where({
						_id:this._id
					}).get().then((res)=>{
						this.detail=res.result.data
						
						 
					})
						
					
				}
				
		}
		
	};
</script>

<style scoped>
	.swipter{
		padding: 40rpx;
	}
	image{
		width:80%;
		height:150px;
		display:block;
		margin:auto;
	}
	.content{
		display: flex;
		justify-content: space-between;
	}
	.title{
		font-size: 20px;
		margin: 5px 10px;
	}
	.total{
		font-size:20px;
		margin:5px 20px;
		color:#B50E03
	}
	.content{
		margin: 5px 10px;
	}
	.adress{
		margin:20px 0px;
	}
	.adressname{
		margin:5px 10px;
		font-size:20px;
	}
	.way{
		margin:20px 0px;
	}
	.waytext{
		margin:5px 10px;
		font-size:14px;
	}
	.timetext{
		margin:5px 10px;
		font-size:14px;
	}
	.warning{
		margin:20px 0px;
	}
	.warning-text{
		display: flex;  
	    flex-direction:column; //灵活的项目将垂直显示，正如一个列一样。
		margin:5px 10px;
		font-size:14px;
		color:red;
	}
</style>
